#ifndef __WIN_H__
#define __WIN_H__

#include "Header.h"

#define ESUTIL_API  __cdecl
#define ESCALLBACK  __cdecl

/// esCreateWindow flag - RGB color buffer
#define ES_WINDOW_RGB           0
/// esCreateWindow flag - ALPHA color buffer
#define ES_WINDOW_ALPHA         1 
/// esCreateWindow flag - depth buffer
#define ES_WINDOW_DEPTH         2 
/// esCreateWindow flag - stencil buffer
#define ES_WINDOW_STENCIL       4
/// esCreateWindow flat - multi-sample buffer
#define ES_WINDOW_MULTISAMPLE   8

typedef struct _Key
{
public:
	__uint8_ Key;
	__bool_ IsPressed;
public:
	_Key() :Key(0), IsPressed(false){}
}Key;

class Win32
{
private:
	const wchar_t* m_wcsTitle;
	__int32_ m_iFlags;
	__uint32_ m_Width;
	__uint32_ m_Height;
	__bool_ m_IsQuit;

	EGLNativeWindowType m_hWnd;
	EGLDisplay m_eglDisplay;
	EGLContext m_eglContext;
	EGLSurface m_eglSurface;
	Key m_Key;
private:
	///Creates an EGL rendering context and all associated elements
	//      Create a window with the specified parameters
	//Input parameters:
	//      hWnd: EGL Windows handle
	//      eglDisplay: Set EGL Display
	//      eglContext: Set EGL Context
	//      eglSurface: Set EGL Surface
	//      attributeList: EGL list attribute
	//Output:
	//      TRUE: Create successful
	//      FALSE: Create fail
	///End
	EGLBoolean esCreateESContext(EGLint attribList[]);

	///Create Client Windows
	///End
	EGLBoolean esCreateClientWindows();

	static LRESULT esWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
public:
	Win32();
	Win32(__uint32_ iWidth, __uint32_ iHeight, const wchar_t* wcsTitle, __uint32_ iFlags);
	~Win32();

	//Get keyboard event
	//Output:
	//      Key struct:
	//              Key
	//              IsPressed
	Key GetKey() { return m_Key; }

	///Initialize View Instance
	//      Static function
	//      It must be call before any orther function.
	//Input Parameters:
	//      esWin32View: Win32 need init
	///End
	static void ESUTIL_API esInitWinView(Win32* esWin32View);

	///Create Windows API
	///End
	EGLBoolean ESUTIL_API esCreateWindows();

	void Update();
	void Destroy();
	__bool_ IsQuit(){ return m_IsQuit; }
};

#endif